package com.xingkeduo.remote;

import com.alibaba.fastjson.JSON;
import com.xingkeduo.dto.ActivityCombinationParam;
import com.xingkeduo.dto.MarketActivityDto;
import com.xingkeduo.dto.OrderDetailResponseDto;
import com.xingkeduo.remote.feign.MarketingFeignService;
import com.xingkeduo.utils.DateTimeUtils;
import com.xingkeduo.utils.ResponseUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@Slf4j
public class MarketingRemoteService {

    @Resource
    private MarketingFeignService marketingFeignService;

    @Resource
    private OrderRemoteService orderRemoteService;



    public MarketActivityDto getMarketActivityInfo(OrderDetailResponseDto order){

        ActivityCombinationParam activityCombinationParam = new ActivityCombinationParam();
        //门店id
        activityCombinationParam.setStoreId(Long.valueOf(order.getStoreId()));
        //发型师id
        activityCombinationParam.setHairdresserId(Long.valueOf(order.getAppointmentAdminId()));
        //该用户关联的用户ids
        activityCombinationParam.setUserId(null);
        //当前登陆用户id
        activityCombinationParam.setUserId(Long.valueOf(order.getUserId()));
        //用户类型 用户类型 0 全部用户，1 星客多新用户，2 门店新用户
        activityCombinationParam.setUserType(orderRemoteService.queryUserType(order.getUserId(),order.getStoreId()));
        //服务id
        activityCombinationParam.setHairServiceId(Long.valueOf(order.getServiceTypeId()));
        //服务原价格
        activityCombinationParam.setHairServiceOriginPrice(order.getAllPrice());
        //预约时间
        activityCombinationParam.setAppointmentDate(DateTimeUtils.yyyy_MM_dd_HH_mm_ss(order.getAppointmentStartTime()));
        log.info("getMarketActivityInfo activityCombinationParam:{}", JSON.toJSONString(activityCombinationParam));
        ResponseUtils<MarketActivityDto> responseUtils= marketingFeignService.getRecommendedPackage(activityCombinationParam);
        MarketActivityDto marketActivityDto = responseUtils.getData();

        return marketActivityDto;

    }


}
